package kr.hyunist.androidcomplete01saeildamil.ch19;

import kr.hyunist.androidcomplete01saeildamil.*;
import android.app.*;
import android.content.*;
import android.content.DialogInterface.*;
import android.os.*;
import android.view.*;
import android.widget.*;

public class UploadEx04 extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.uploadex);
	}

	public void mOnClick(View v) {
		new AlertDialog.Builder(this).setTitle("업로드").setMessage("업로드 할래?")
				.setPositiveButton("예", new OnClickListener() {

					@Override
					public void onClick(DialogInterface dialog, int which) {
						Button btn = (Button) findViewById(R.id.uploadbtn);
						btn.postDelayed(new Runnable() {

							@Override
							public void run() {
								doUpload();
							}

						}, 10);
					}

				}).setNegativeButton("아니오", null).show();
	}

	private void doUpload() {
		for (int i = 0; i < 20; i++) {
			try {
				Thread.sleep(100);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		Toast.makeText(this, "업로드 완료", 0).show();
	}
}
